#!/usr/bin/env bash

source /etc/profile
if [ $# -eq 1 ]; then
	targetHour=$1
else
	targetHour=`date -d "-1 hours" +"%Y%m%d%H"`
fi
path=$(cd $(dirname $0);pwd)
parentPath=$(dirname ${path})
targetDate=${targetHour:0:8}
if [ ! -d "${path}/${targetDate}/behaviour" ];then
	mkdir -p ${path}/${targetDate}/behaviour
fi


source ${parentPath}/configs/mysql_config

path_prefix=${path}/${targetDate}/behaviour/${targetHour}

hdfspath="/user/work/trackingFormatLog/${targetDate}/*"
hdfs_tmppath="/tmp/log_duration"

hadoop fs -mkdir -p ${hdfs_tmppath}
hadoop fs -rm -r ${hdfs_tmppath}/${targetDate}
hadoop jar ${parentPath}/lib/hadoop-streaming-2.7.2.jar -file ${path}/mapper.py -mapper ${path}/mapper.py -file ${path}/reducer.py -reducer ${path}/reducer.py -input ${hdfspath} -output ${hdfs_tmppath}/${targetDate}

#drop table nas_tmp_duration;
hive -e "use formatlog;create external table if not exists nas_tmp_duration(session string, duration int, cid string, sid string, curdate int,nasid string, ep string, ip string,sis string,sisurl string,referer_type string,eventid int,entry_flag int,exit_flag int) partitioned by (day int) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'  STORED AS INPUTFORMAT \"org.apache.hadoop.mapred.TextInputFormat\" OUTPUTFORMAT \"org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat\" location '${hdfs_tmppath}';"
hive -e"use formatlog;alter table nas_tmp_duration drop if exists partition(day=${targetDate});"
hive -e"use formatlog;alter table nas_tmp_duration add if not exists partition(day=${targetDate}) location '${hdfs_tmppath}/${targetDate}';"
wait

#转化次数计算
python ${path}/ReadfromMysql.py ${host} ${port} ${user} ${password} ${db} "cpid,cid,sid,pages" "nas_conversion_page" > ${path_prefix}_page.txt
python ${path}/ReadfromMysql.py ${host} ${port} ${user} ${password} ${db} "cid,sid,eid,times" "nas_conversion_event" > ${path_prefix}_event.txt
python ${path}/ReadfromMysql.py ${host} ${port} ${user} ${password} ${db} "cid,sid,ctid,time" "nas_conversion_time" > ${path_prefix}_time.txt

#入口页
hive -e "set hive.auto.convert.join=false;set mapred.job.name=[NAS][behaviour][entryurl][${targetHour}];use formatlog;add file ${path}/getconversion.py ${path_prefix}_page.txt ${path_prefix}_time.txt ${path_prefix}_event.txt;insert overwrite local directory '${path_prefix}_entry_analysis' select a.cid,a.sid,${targetDate},a.ep,count(1) as entrycount,count(distinct a.nasid),avg(a.duration),sum(if(a.exit_flag=1,1,0)),sum(b.pv),count(distinct a.session),count(distinct a.ip) as ip,sum(cast(a.connum as int)) as conversions from (select transform(cid,sid,session,nasid,duration,exit_flag,ip,ep,eventid) using 'python getconversion.py ${targetHour}_page.txt ${targetHour}_event.txt ${targetHour}_time.txt' as (cid,sid,session,nasid,duration,exit_flag,ip,ep,connum) from nas_tmp_duration where day=${targetDate} and entry_flag=1 ) a join (select cid,sid,session,count(1) pv from nas_tmp_duration where day=${targetDate} group by cid,sid,session) b on a.sid =b.sid and a.sid=b.sid and a.session=b.session group by a.cid,a.sid,a.ep;"
cat ${path_prefix}_entry_analysis/* > ${path_prefix}_entry_analysis.txt
#访问页
hive -e "set mapred.job.name=[NAS][behaviour][visiturl][${targetHour}];use formatlog;add file ${path}/getconversion.py ${path_prefix}_page.txt ${path_prefix}_time.txt ${path_prefix}_event.txt;insert overwrite local directory '${path_prefix}_visit_analysis' select a.cid,a.sid,${targetDate},a.ep,count(1) as scan_count,count(distinct a.nasid),count(distinct a.ip) as ip,avg(a.duration),sum(if(a.exit_flag=1,1,0)),count(distinct a.session),sum(cast(a.connum as int)) as conversions from (select transform(cid,sid,session,nasid,duration,exit_flag,ip,ep,eventid) using 'python getconversion.py ${targetHour}_page.txt ${targetHour}_event.txt ${targetHour}_time.txt' as (cid,sid,session,nasid,duration,exit_flag,ip,ep,connum) from nas_tmp_duration where day=${targetDate} ) a group by a.cid,a.sid,a.ep;"
cat ${path_prefix}_visit_analysis/* > ${path_prefix}_visit_analysis.txt
#出口页
hive -e "set mapred.job.name=[NAS][behaviour][exiturl][${targetHour}];use formatlog;add file ${path}/getconversion_exit.py ${path_prefix}_page.txt ${path_prefix}_event.txt;insert overwrite local directory '${path_prefix}_exit_analysis' select a.cid,a.sid,${targetDate},a.ep,count(1) as exitcount,count(distinct a.nasid),avg(a.duration),sum(if(a.entry_flag=1,1,0)),count(distinct a.session),count(distinct a.ip) as ip,sum(cast(a.connum as int)) as conversions  from (select transform(cid,sid,session,nasid,duration,entry_flag,ip,ep,eventid) using 'python getconversion_exit.py ${targetHour}_page.txt ${targetHour}_event.txt' as (cid,sid,session,nasid,duration,entry_flag,ip,ep,connum) from nas_tmp_duration where day=${targetDate} and exit_flag = 1) a group by a.cid,a.sid,a.ep;"
cat ${path_prefix}_exit_analysis/* > ${path_prefix}_exit_analysis.txt

#站内搜索
hive -e "set mapred.job.name=[NAS][behaviour][innersearch][${targetHour}];use formatlog;insert overwrite local directory '${path_prefix}_query_analysis' select a.cid,a.sid,${targetDate},count(1) as sispv,count(distinct a.nasid),max(b.pv),sum(if(a.exit_flag=1,1,0)) as exit,count(distinct a.session) from (select cid,sid,session,sis,nasid,exit_flag from nas_tmp_duration where day=${targetDate} and sis <> '-' ) a left outer join (select cid,sid,count(1) pv from nas_tmp_duration where day=${targetDate}  and sis <> '-' and sisurl <> '-' group by cid,sid) b on a.cid= b.cid and a.sid= b.sid  group by a.cid,a.sid;"
cat ${path_prefix}_query_analysis/*  > ${path_prefix}_query_analysis.txt
#路径分析
#hive -e "set mapred.job.name=[NAS][behaviour][visitpath][${targetHour}];add file ${path}/path_visit.py;use formatlog;insert overwrite local directory '${path_prefix}_path_analysis' select b.cid,b.sid,b.first_url,b.second_url,b.three_url,b.day from (select transform (a.cid,a.sid,a.session,a.time,a.url) using 'python path_visit.py' as (cid,sid,first_url,second_url,three_url,day) from (select cid,sid,session,time,min(ep) as url from nas_tracking_format_hour where day=${targetDate} and ep <> \"\" group by cid,sid,session,time,ep order by cid,sid,session,time) a ) b group by b.cid,b.sid,b.first_url,b.second_url,b.three_url,b.day;"

#hive -e "add jar ${parentPath}/lib/NASUDF-0.0.1.jar;create temporary function geturlhost as 'com.nsw.udf.GetUrlHost';set mapred.job.name=[NAS][behaviour][visitpath][${targetHour}];add file ${path}/format_visit_path3.py;use formatlog;insert overwrite local directory '${path_prefix}_path_analysis' select d.cid,d.sid,d.referer,d.page1,d.page2,d.page3,d.page4,d.day,d.pv from (select c.cid,c.sid,c.referer,c.page1,c.page2,c.page3,c.page4,c.day,count(1) as pv from (select transform(b.cid,b.sid,${targetDate},b.referer,b.eps) using 'python format_visit_path3.py' as cid,sid,referer,page1,page2,page3,page4,day from (select a.cid,a.sid,a.session,min(struct(a.time,geturlhost(a.referer))).col2 as referer,concat_ws(',',collect_list(a.ep)) as eps from (select cid,sid,session,time,referer,ep from nas_tracking_format_hour where day=${targetDate} distribute by cid,sid,session sort by cid,sid,session,time ASC) a group by a.cid,a.sid,a.session) b where b.referer<>'unknown') c group by c.cid,c.sid,c.referer,c.page1,c.page2,c.page3,c.page4,c.day) d order by d.pv DESC limit 5"
# 20161103
#hive -e "use formatlog;add jar ${parentPath}/lib/NASUDF-0.0.1.jar;create temporary function geturlhost as 'com.nsw.udf.GetUrlHost';create temporary function changepath as 'com.nsw.udf.ChangePath';set mapred.job.name=[NAS][behaviour][visitpath][${targetHour}];insert overwrite local directory '${path_prefix}_path_analysis' select d.cid,d.sid,d.referer,d.page1,d.page2,d.page3,d.page4,${targetDate},d.visits from (select c.cid,c.sid,c.referer,c.page1,c.page2,c.page3,c.page4,c.visits,row_number() over (partition by c.cid,c.sid order by c.visits desc) rank from (select b.cid,b.sid,if(changepath(b.referer,b.eps[0]),'直接来源',b.referer) as referer,if(changepath(b.referer,b.eps[0]),b.referer,b.eps[0]) as page1,if(changepath(b.referer,b.eps[0]),b.eps[0],b.eps[1]) as page2,if(changepath(b.referer,b.eps[0]),b.eps[1],b.eps[2]) as page3,if(changepath(b.referer,b.eps[0]),b.eps[2],b.eps[3]) as page4,count(distinct b.session) as visits from (select a.cid,a.sid,a.session,min(struct(a.time,geturlhost(a.referer))).col2 as referer,collect_list(a.ep) as eps from (select cid,sid,session,time,referer,ep from nas_tracking_format_hour where day=${targetDate} distribute by cid,sid,session sort by cid,sid,session,time ASC) a group by a.cid,a.sid,a.session) b where b.referer<>'unknown' group by b.cid,b.sid,if(changepath(b.referer,b.eps[0]),'直接来源',b.referer),if(changepath(b.referer,b.eps[0]),b.referer,b.eps[0]),if(changepath(b.referer,b.eps[0]),b.eps[0],b.eps[1]),if(changepath(b.referer,b.eps[0]),b.eps[1],b.eps[2]),if(changepath(b.referer,b.eps[0]),b.eps[2],b.eps[3])) c where c.referer!=c.page1 and c.page1!=c.page2 and c.page2!=c.page3 and c.page3!=c.page4 and (c.referer like 'http%' or c.referer='直接来源') and c.page1 like 'http%' and c.page2 like 'http%' and c.page3 like 'http%' and c.page4 like 'http%') d where d.rank<=5;"
#cat ${path_prefix}_path_analysis/* > ${path_prefix}_path_analysis.txt

hive -e "set mapred.job.name=[NAS][behaviour][visitpath][${targetHour}];use formatlog;add jar ${parentPath}/lib/NASUDF-0.0.1.jar;create temporary function formatreferer as 'com.nsw.udf.FormatReferer';drop table if exists tmp_visit_path;create table tmp_visit_path as select b.cid,b.sid,b.session,b.referer,b.eps from (select a.cid,a.sid,a.session,min(struct(a.time,formatreferer(a.referer,a.ep))).col2 as referer,collect_list(a.ep) as eps from (select cid,sid,session,time,referer,ep from formatlog.nas_tracking_format_hour where day=${targetDate} distribute by cid,sid,session sort by cid,sid,session,time ASC) a group by a.cid,a.sid,a.session) b where b.referer is not null and b.eps[0] like 'http%';drop table if exists tmp_visit_path_referer;create table tmp_visit_path_referer as select cid,sid,if(rank==6,'其它',max(referer)) as referer,sum(sessions) as sessions from (select cid,sid,referer,sessions,if(rank>5,6,rank) as rank from (select cid,sid,referer,sessions,ROW_NUMBER() OVER (PARTITION BY cid,sid ORDER BY sessions DESC) as rank from (select cid,sid,referer,count(distinct session) as sessions from tmp_visit_path group by cid,sid,referer) a) b) c group by cid,sid,rank;drop table if exists tmp_visit_path_page1;create table tmp_visit_path_page1 as select cid,sid,referer,if(rank==6,'其它',max(page1)) as page1,sum(sessions) as sessions from (select cid,sid,referer,page1,sessions,if(rank>5,6,rank) as rank from (select cid,sid,referer,page1,sessions,ROW_NUMBER() OVER (PARTITION BY cid,sid,referer ORDER BY sessions DESC) as rank from (select a.cid,a.sid,a.referer,a.page1,a.sessions from (select cid,sid,referer,eps[0] as page1,count(distinct session) as sessions from tmp_visit_path group by cid,sid,referer,eps[0]) a left semi join tmp_visit_path_referer b on (a.cid=b.cid and a.sid=b.sid and a.referer=b.referer)) c) d) e group by cid,sid,referer,rank;drop table if exists tmp_visit_path_page2;create table tmp_visit_path_page2 as select cid,sid,referer,page1,if(rank==6,'其它',if(max(page2) is null,'离开',max(page2))) as page2,sum(sessions) as sessions from (select cid,sid,referer,page1,page2,sessions,if(rank>5,6,rank) as rank from (select cid,sid,referer,page1,page2,sessions,ROW_NUMBER() OVER (PARTITION BY cid,sid,referer,page1 ORDER BY sessions DESC) as rank from (select a.cid,a.sid,a.referer,a.page1,a.page2,a.sessions from (select cid,sid,referer,eps[0] as page1,eps[1] as page2,count(distinct session) as sessions from tmp_visit_path group by cid,sid,referer,eps[0],eps[1]) a left semi join tmp_visit_path_page1 b on (a.cid=b.cid and a.sid=b.sid and a.referer=b.referer and a.page1=b.page1)) c) d) e group by cid,sid,referer,page1,rank;drop table if exists tmp_visit_path_page3;create table tmp_visit_path_page3 as select cid,sid,referer,page1,page2,if(rank==6,'其它',if(max(page3) is null,'离开',max(page3))) as page3,sum(sessions) as sessions from (select cid,sid,referer,page1,page2,page3,sessions,if(rank>5,6,rank) as rank from (select cid,sid,referer,page1,page2,page3,sessions,ROW_NUMBER() OVER (PARTITION BY cid,sid,referer,page1,page2 ORDER BY sessions DESC) as rank from (select a.cid,a.sid,a.referer,a.page1,a.page2,a.page3,a.sessions from (select cid,sid,referer,eps[0] as page1,eps[1] as page2,eps[2] as page3,count(distinct session) as sessions from tmp_visit_path group by cid,sid,referer,eps[0],eps[1],eps[2]) a left semi join tmp_visit_path_page2 b on (a.cid=b.cid and a.sid=b.sid and a.referer=b.referer and a.page1=b.page1 and a.page2 is not null and a.page2=b.page2)) c) d) e group by cid,sid,referer,page1,page2,rank;drop table if exists tmp_visit_path_page4;create table tmp_visit_path_page4 as select cid,sid,referer,page1,page2,page3,if(rank==6,'其它',if(max(page4) is null,'离开',max(page4))) as page4,sum(sessions) as sessions from (select cid,sid,referer,page1,page2,page3,page4,sessions,if(rank>5,6,rank) as rank from (select cid,sid,referer,page1,page2,page3,page4,sessions,ROW_NUMBER() OVER (PARTITION BY cid,sid,referer,page1,page2,page3 ORDER BY sessions DESC) as rank from (select a.cid,a.sid,a.referer,a.page1,a.page2,a.page3,a.page4,a.sessions from (select cid,sid,referer,eps[0] as page1,eps[1] as page2,eps[2] as page3,eps[3] as page4,count(distinct session) as sessions from tmp_visit_path group by cid,sid,referer,eps[0],eps[1],eps[2],eps[3]) a left semi join tmp_visit_path_page3 b on (a.cid=b.cid and a.sid=b.sid and a.referer=b.referer and a.page1=b.page1 and a.page2=b.page2 and a.page3 is not null and a.page3=b.page3)) c) d) e group by cid,sid,referer,page1,page2,page3,rank;insert overwrite local directory '${path_prefix}/visit_path_result/referer' select cid,sid,concat('1_',referer),sessions from tmp_visit_path_referer;insert overwrite local directory '${path_prefix}/visit_path_result/page1_2' select cid,sid,concat('1_',referer),concat('2_',page1),sessions from (select d.cid,d.sid,d.referer,d.page1,d.sessions,ROW_NUMBER() OVER (PARTITION BY cid,sid ORDER BY sessions DESC) as rank from (select c.cid,c.sid,'其它' as referer,c.page1,count(distinct c.session) as sessions from (select /*+ MAPJOIN(b) */ a.cid,a.sid,a.referer,a.eps[0] as page1,a.session from tmp_visit_path a join (select cid,sid,collect_set(referer) as referers from tmp_visit_path_referer group by cid,sid) b where a.cid=b.cid and a.sid=b.sid and not array_contains(b.referers,a.referer)) c group by c.cid,c.sid,c.page1) d) e where rank<=5;insert overwrite local directory '${path_prefix}/visit_path_result/page1' select cid,sid,concat('1_',referer),concat('2_',page1),sessions from tmp_visit_path_page1;insert overwrite local directory '${path_prefix}/visit_path_result/page2' select cid,sid,concat('1_',referer),concat('2_',page1),concat('3_',page2),sessions from tmp_visit_path_page2;insert overwrite local directory '${path_prefix}/visit_path_result/page3' select cid,sid,concat('1_',referer),concat('2_',page1),concat('3_',page2),concat('4_',page3),sessions from tmp_visit_path_page3;insert overwrite local directory '${path_prefix}/visit_path_result/page4' select cid,sid,concat('1_',referer),concat('2_',page1),concat('3_',page2),concat('4_',page3),concat('5_',page4),sessions from tmp_visit_path_page4;"
wait
cat ${path_prefix}/visit_path_result/referer/* > ${path_prefix}/visit_path_result/referer.txt
cat ${path_prefix}/visit_path_result/page1/* ${path_prefix}/visit_path_result/page1_2/*> ${path_prefix}/visit_path_result/page1.txt
cat ${path_prefix}/visit_path_result/page2/* > ${path_prefix}/visit_path_result/page2.txt
cat ${path_prefix}/visit_path_result/page3/* > ${path_prefix}/visit_path_result/page3.txt
cat ${path_prefix}/visit_path_result/page4/* > ${path_prefix}/visit_path_result/page4.txt

#频道分析
#hive -e "set mapred.job.name=[NAS][behaviour][visitpath][${targetHour}];use formatlog;add file ${path}/format_visit_path2.py;create table if not exists tmp_nas_visit_path(cid string,sid string,session string,nasid string,pv bigint,page1 string,page2 string,page3 string);insert overwrite table tmp_nas_visit_path select transform(b.cid,b.sid,b.session,b.pv,b.nasid,b.referer,b.eps) using 'python format_visit_path2.py' as cid,sid,session,nasid,pv,page1,page2,page3 from (select a.cid,a.sid,a.session,min(struct(time,referer)).col2 as referer,concat_ws(',',collect_list(a.ep)) as eps,count(1) as pv,max(a.nasid) as nasid from (select cid,sid,session,time,ep,referer,nasid from nas_tracking_format_hour where day=${targetDate} and length(cid)>0 and length(sid)>0 distribute by cid,sid,session sort by cid,sid,session,time ASC) a group by a.cid,a.sid,a.session) b;insert overwrite local directory '${path_prefix}_page2_analysis' select cid,sid,page2,${targetDate},sum(pv) as pv,count(1) as session,count(distinct nasid) as uv from tmp_nas_visit_path group by cid,sid,page2;insert overwrite local directory '${path_prefix}_path_analysis' select cid,sid,page1,page2,page3,${targetDate},sum(pv),count(1),count(distinct nasid) from tmp_nas_visit_path group by cid,sid,page1,page2,page3;"
#cat ${path_prefix}_page2_analysis/* > ${path_prefix}_page2_analysis.txt
#cat ${path_prefix}_path_analysis/* > ${path_prefix}_path_analysis.txt

#搜索词
#hive -e "set mapred.job.name=[NAS][behaviour][innersearchword][${targetHour}];use formatlog;insert overwrite local directory '${path_prefix}_word_analysis' select b.cid,b.sid,${targetDate},trim(b.query),b.pv,b.uv,split(c.maxurl,'-')[1] from ( select cid,sid,query,count(1) pv ,count(distinct nasid) uv  from nas_tracking_format_hour where day=${targetDate} and query <> \"\" group by cid,sid,query) b  join (select a.cid,a.sid,a.query, max(concat_ws('-',format_number(a.pv,0),a.ep)) as maxurl from ( select cid,sid,query,ep,count(1) pv from nas_tracking_format_hour where day=${targetDate} and query <> \"\" group by cid,sid,query,ep) a group by cid,sid,query) c on b.cid=c.cid and b.sid=c.sid and b.query=c.query;"
cd ${parentPath}
#hive -e "set mapred.job.name=[NAS][behaviour][innersearchword][${targetHour}];use formatlog;add files ${parentPath}/page.txt ${parentPath}/event.txt ${parentPath}/time.txt ${parentPath}/pagenum.txt;add jar ${parentPath}/lib/NASUDF-0.0.1.jar;create temporary function getconversion as 'com.nsw.udf.GetConversion';insert overwrite local directory '${path_prefix}_word_analysis' select a.cid,a.sid,${targetDate},a.sis,count(1) as soucount, count(distinct a.nasid) as uv,max(d.sisurl), count(distinct a.session) as totalsession,count(distinct b.conversions) as conversion from (select cid,sid,session,nasid,trim(sis) as sis from nas_tracking_format_hour where day=${targetDate} and cid is not null and sid is not null and trim(sis) is not null and referertype=4) a join (select cid,sid,session,getconversion(cid,sid,concat_ws(',',collect_set(sisurl)),concat_ws(',',collect_list(cast(eventid as string))),(max(time)-min(time))/1000+60) as conversions from nas_tracking_format_hour where day=${targetDate} group by cid,sid,session) b on a.cid=b.cid and a.sid=b.sid and a.session=b.session join (select e.cid,e.sid,e.sis, max(struct(e.pv,e.sisurl)).col2 as sisurl from (select cid,sid,sis,sisurl,count(1) pv from nas_tracking_format_hour where day=${targetDate} and cid is not null and sid is not null and sis is not null group by cid,sid,sis,sisurl) e group by e.cid,e.sid,e.sis ) d on a.cid=d.cid and a.sid=d.sid and a.sis = d.sis group by a.cid,a.sid,a.sis;"
hive -e "set mapred.job.name=[NAS][behaviour][innersearchword][${targetHour}];use formatlog;add files ${parentPath}/page.txt ${parentPath}/event.txt ${parentPath}/time.txt ${parentPath}/pagenum.txt;add jar ${parentPath}/lib/NASUDF-0.0.1.jar;create temporary function getconversion as 'com.nsw.udf.GetConversion';insert overwrite local directory '${path_prefix}_word_analysis' select a.cid,a.sid,${targetDate},a.sis,count(1) as soucount, count(distinct a.nasid) as uv,max(d.sisurl), count(distinct a.session) as totalsession,count(distinct b.conversions) as conversion from (select cid,sid,session,nasid,sis from nas_tmp_duration where day=${targetDate} and  sis <>'-') a join (select cid,sid,session,getconversion(cid,sid,concat_ws(',',collect_set(sisurl)),concat_ws(',',collect_list(cast(eventid as string))),(max(time)-min(time))/1000+60) as conversions from nas_tracking_format_hour where day=${targetDate} group by cid,sid,session) b on a.cid=b.cid and a.sid=b.sid and a.session=b.session left outer join (select e.cid,e.sid,e.sis, max(struct(e.pv,e.sisurl)).col2 as sisurl from 	(select cid,sid,sis,sisurl,count(1) pv from nas_tmp_duration where day=${targetDate}  and sis <>'-' and sisurl <> '-' group by cid,sid,sis,sisurl) e group by e.cid,e.sid,e.sis) d on a.cid=d.cid and a.sid=d.sid and a.sis = d.sis group by a.cid,a.sid,a.sis;"
cat ${path_prefix}_word_analysis/* > ${path_prefix}_word_analysis.txt

wait


#table nas_behaviour_entryurl
python ${path}/load_behaviour_entryUrl_to_mysql.py ${path_prefix}_entry_analysis.txt ${host} ${port} ${user} ${password} ${db} ${targetDate}
#nas_behaviour_exiturl
python ${path}/load_behaviour_exitUrl_to_mysql.py ${path_prefix}_exit_analysis.txt ${host} ${port} ${user} ${password} ${db} ${targetDate}
#nas_behaviour_innersearch
python ${path}/load_behaviour_innersearch_to_mysql.py ${path_prefix}_query_analysis.txt ${host} ${port} ${user} ${password} ${db} ${targetDate}
#nas_behaviour_innersearchword
python ${path}/load_behaviour_innersearchword_to_mysql.py ${path_prefix}_word_analysis.txt ${host} ${port} ${user} ${password} ${db} ${targetDate}
#nas_behaviour_visiturl
python ${path}/load_behaviour_visitUrl_to_mysql.py ${path_prefix}_visit_analysis.txt ${host} ${port} ${user} ${password} ${db} ${targetDate}
#nas_behaviour_visitpath
#python ${path}/load_behaviour_visitPath_to_mysql.py ${path_prefix}_path_analysis.txt ${host} ${port} ${user} ${password} ${db} ${targetDate}
#python ${path}/load_behaviour_page2_to_mysql.py ${path_prefix}_page2_analysis.txt ${host} ${port} ${user} ${password} ${db} ${targetDate}

python ${path}/load_behaviour_visitPath_to_mysql2.py ${path_prefix}/visit_path_result/referer.txt ${host} ${port} ${user} ${password} ${db} ${targetDate} '1'
python ${path}/load_behaviour_visitPath_to_mysql2.py ${path_prefix}/visit_path_result/page1.txt ${host} ${port} ${user} ${password} ${db} ${targetDate} '2'
python ${path}/load_behaviour_visitPath_to_mysql2.py ${path_prefix}/visit_path_result/page2.txt ${host} ${port} ${user} ${password} ${db} ${targetDate} '3'
python ${path}/load_behaviour_visitPath_to_mysql2.py ${path_prefix}/visit_path_result/page3.txt ${host} ${port} ${user} ${password} ${db} ${targetDate} '4'
python ${path}/load_behaviour_visitPath_to_mysql2.py ${path_prefix}/visit_path_result/page4.txt ${host} ${port} ${user} ${password} ${db} ${targetDate} '5'
